package profiterole.samples;

import java.io.File;
import java.util.LinkedList;
import java.util.List;
import java.util.Scanner;

import profiterole.api.Waffle;
import profiterole.mapreduce.MapReduceService;

public class REPL {

	public static void main(String[] args) {
		
		String input;
		List<File> arr = new LinkedList<File>(); 		
    	File path = new File(System.getProperty("user.dir") +"/MapJobs/");

        File [] files = path.listFiles();
        for (int i = 0; i < files.length; i++) {
            if (files[i].isFile()) { //this line weeds out other directories/folders
            	arr.add(files[i]);
            }
        }
    	  	
        Waffle<?> result = MapReduceService.mapReduce(arr);
    	System.out.println();
		Scanner sc = new Scanner(System.in);
	
		while (true) {
			System.out.print("$");
			input = sc.nextLine();
			System.out.println(input + "word count " + result.get(input));
		}
	}		
}